#ifndef POLYNOMIAL_H
#define POLY0NOMIAL_H

#include<iostream>
#include<sstream>
#include<string>
#include<cstdlib>
#include<vector>
#include<math.h>
#include<complex>

#if !(( defined(_MSC_VER) && _MSC_VER<=1200 ) || defined(__DMC__))
using namespace std;
#endif

typedef complex<double> dcmpx;



template<class T>
string ToString(const T& val)
{
    stringstream strm;
    strm << val;
    return strm.str();
}

class PolyTerm{//single variable
private:
	double coef,expo;
public:
	double get_coef(){return coef;}
	double get_exp(){return expo;}
	double degree(){return expo;}
	
	void set_coef(double c){coef=c;}
	void set_exp(double e){expo=e;}
	

	
	PolyTerm(){coef=1;expo=0;}
	PolyTerm(double c, double e){coef=c;expo=e;}

	//~PolyTerm(){delete this;}
	
	/*
	PolyTerm operator()(const PolyTerm& pt1,constPolyTerm& pt2)
	//add/sub(like terms only), mult/div,
	*/
};

class Polynomial{
private:
	vector<PolyTerm> Terms;
	double read_num(string s,int *i);//reads a number is string s at position i
	int is_num(char c){if((c>=48&&c<=57)||(c=='.')) return -1; else return 0;}//tests to see if the character is a number	
	int is_var(char c){if((c>=65&&c<=90)||(c>=97&&c<=122)) return -1; else return 0;}//tests to see if the character is a number	
	int error_num;//0-no error, 1-non-critical error, -1-critical error
	string error;
public:	
	Polynomial(){PolyTerm *pt=new PolyTerm(); Terms.push_back(*pt);error_num=0;}//Creates a unit polynomial
	Polynomial(string strPolyn);//accepts polynomial string

	~Polynomial();//{delete this;}//destructor
	
	int has_error(){return error_num;}
	
	string get_error(){return error;}

	string print();//{cout<<"x"<<endl;}
	
	double eval(double);
	
	dcmpx eval(dcmpx);
	/*
	Polynomial operator()(const Polynomial& p1,constPolynomial& p2)
	//add/sub(like terms only), mult/div,
	*/

};

#endif
